<div class='field'>
  <div id='page-tabs' class='clearfix ui-tabs ui-widget ui-widget-content ui-corner-all'>
    <ul id='page_parts'>
      <% tabbed_fields.each_with_index do |field, index| %>
        <li class="ui-state-default <%= 'ui-state-active' if index == 0 %>">
          <%= link_to "#{field.to_s.humanize}", "\##{field}" %>
        </li>
      <% end %>
      <% pages_tabs = ::Refinery::Pages.tabs
         tabs_to_show = (refinery_pages_tabs ||= []).map!(&:to_s)
         pages_tabs.reject!{ |t| refinery_pages_tabs.exclude?(t.name.to_s) } unless tabs_to_show.include?('all')
         pages_tabs.each_with_index do |tab, tab_index| %>
        <li class='ui-state-default' id="custom_<%= tab.name %>_tab">
          <%= link_to tab.name.titleize, "#custom_tab_#{tab_index}" %>
        </li>
      <% end %>
    </ul>

    <div id='page_part_editors'>
      <% tabbed_fields.each do |field| %>
        <div class='page_part' id="<%= field %>">
          <%= f.text_area field, :rows => 20, :class => 'visual_editor widest' -%>
        </div>
      <% end %>
      <% pages_tabs.each_with_index do |tab, tab_index| %>
        <div class='page_part' id='<%= "custom_tab_#{tab_index}" %>'>
          <%= render tab.partial, :f => f %>
        </div>
      <% end %>
    </div>
  </div>
</div>

<% content_for :javascripts do %>
  <script>
    $(document).ready(function(){
      if (!page_options.initialised) {
        page_options.init(false, '', '');
      }
    });
  </script>
<% end %>
